//package com.wst.business.controller;
//
//import com.alibaba.fastjson2.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.wst.system.security.IsAdmin;
//import com.wst.system.util.ResultUtil;
//import com.wst.system.config.exception.GlobalExcetion;
//
//import java.io.IOException;
//import java.io.Serializable;
//
//import com.wst.system.util.SpringContextUtils;
//import com.wst.system.util.jdbc.DBSql;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import com.wst.business.service.ShardingDsService;
//import com.wst.business.entity.ShardingDs;
//import com.wst.business.entity.vo.ShardingDsVo;
//import org.springframework.validation.annotation.Validated;
//
//import java.sql.SQLException;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
//import com.wst.system.config.PageData;
//
//
///**
// * <p>
// *  前端控制器
// * </p>
// *
// * @author X.I.O
// * @since 2025-01-13
// */
//
//@RestController
//@Api(tags = {"的服务类"})
//@RequestMapping("/sharding-ds")
//public class ShardingDsController {
//
//        @Autowired
//        private ShardingDsService shardingDsService;
//
//
//        @PostMapping("/saveorupdate")
//        @ApiOperation(value = "的新增/更新接口",notes = "的新增接口")
//        public JSONObject save(@RequestBody @Validated ShardingDsVo shardingDs01Vo) throws GlobalExcetion{
//                shardingDsService.saveOrUpdateShardingDs(shardingDs01Vo);
//            return ResultUtil.successInfo("操作成功");
//        }
//
//
//        @PostMapping("/save")
//        @ApiOperation(value = "的新增接口",notes = "的新增接口")
//        public JSONObject save(@RequestBody ShardingDs shardingDs01) throws GlobalExcetion{
//                shardingDsService.saveShardingDs(shardingDs01);
//            return ResultUtil.successInfo("保存成功");
//        }
//
//
//        @PostMapping("/update")
//        @ApiOperation(value = "的更新接口",notes = "的更新接口")
//        public JSONObject update(@RequestBody ShardingDs shardingDs01) throws GlobalExcetion{
//            shardingDsService.updateShardingDsById(shardingDs01);
//            return ResultUtil.successInfo("更新成功");
//        }
//
//
//
//        @DeleteMapping("/delbyid")
//        @ApiOperation(value = "的删除接口",notes = "的删除接口")
//        public JSONObject delete(@RequestParam("id") Serializable id) throws GlobalExcetion{
//            boolean flag = shardingDsService.removeById(id);
//            if(flag){
//                return ResultUtil.successInfo("删除成功");
//            }else {
//                return ResultUtil.errorInfo("删除失败");
//            }
//        }
//
//        @PostMapping("/del/batch")
//        @ApiOperation(value = "的批量删除接口",notes = "的批量删除接口")
//        public JSONObject deleteBatch(@RequestBody List<Integer> ids) throws GlobalExcetion {
//            boolean flag =  shardingDsService.removeByIds(ids);
//            if(flag){
//                return ResultUtil.successInfo("删除成功");
//            }else {
//                return ResultUtil.errorInfo("删除失败");
//            }
//        }
//
//        @GetMapping("/getall")
//        @ApiOperation(value = "的获取全部接口",notes = "的获取全部接口")
//        public JSONObject findAll() throws GlobalExcetion {
//            LambdaQueryWrapper<ShardingDs> dsLambdaQueryWrapper=new LambdaQueryWrapper<>();
//            List<ShardingDs> list= shardingDsService.list(dsLambdaQueryWrapper);
//            return ResultUtil.successInfo(list);
//        }
//
//        @GetMapping("/getbyid")
//        @ApiOperation(value = "的获取一个接口",notes = "的获取一个接口")
//        public JSONObject findOne(@RequestParam("id") Serializable id) throws GlobalExcetion {
//            ShardingDs data= shardingDsService.getById(id);
//            return ResultUtil.successInfo(data);
//        }
//
//        @IsAdmin
//        @GetMapping("/page")
//        @ApiOperation(value = "的分页接口",notes = "的分页接口")
//        public JSONObject findPage(@RequestParam(value = "page",defaultValue = "1") Integer page,
//                                   @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
//                                   @RequestParam(value = "name")String name) throws GlobalExcetion {
//            IPage<ShardingDs> data=shardingDsService.page(page, pageSize,name);
//            PageData pageData=new PageData(data.getTotal(),page,pageSize,data.getRecords());
//            return ResultUtil.successInfo(pageData);
//        }
//
//        @GetMapping("page2")
//        public JSONObject page2() throws SQLException, IOException {
//            DBSql dbSql= (DBSql) SpringContextUtils.getBean("ds_01");
//            List<Map<String,Object>> mapList=dbSql.getMaps("select * from sharding_ds_01",new Object[]{});
//            return ResultUtil.successInfo(mapList);
//        }
//}

